<?
################################################################################
##              -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =-                 #
## --------------------------------------------------------------------------- #
##  PHP AdminPanel Free                                                        #
##  Developed by:  ApPhp <info@apphp.com>                                      # 
##  License:       GNU GPL v.2                                                 #
##  Site:          http://www.apphp.com/php-adminpanel/                        #
##  Copyright:     PHP AdminPanel (c) 2006-2009. All rights reserved.          #
##                                                                             #
##  Additional modules (embedded):                                             #
##  -- PHP DataGrid 4.2.8                   http://www.apphp.com/php-datagrid/ #
##  -- JS AFV 1.0.5                 http://www.apphp.com/js-autoformvalidator/ #
##  -- jQuery 1.1.2                                         http://jquery.com/ #
##                                                                             #
################################################################################

    // Initialize the session.
    session_start();
    include "pages/inicio.php";
    require_once("inc/checkAdminPagePermissions.php");
    require_once("inc/config.inc.php");
    require_once("inc/database.inc.php");
    require_once("inc/settings.inc.php");
    
    $menu_group_index = 0;
    $menu_group_count = 0;

    $db=new Database();	
    $db->open();

    $db2=new Database();	
    $db2->open();
    $criterio="";
	$cadena="";
	 if ($_SESSION['tipousuario'] =="Usuario") $criterio=" and  idusuario=1 ";
	 $cadena="SELECT *
        FROM "._DB_PREFIX."menu
        WHERE
            is_menu_group = 1 AND
            is_hidden = 0 AND
            is_dashboard_icon = 1 
        ORDER BY order_index ASC";
	
    $db->query($cadena);
		
    $menu_group_count = $db->numRows();
    
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
    <title><?=$SETTINGS['site_name'];?> :: Panel Administrativo :: Inicio</title>
    <meta http-equiv=Content-Type content="text/html; charset=utf-8">
    <!-- CSS style files -->
    <link href="css/style_<?=$SETTINGS['css_style'];?>.css" type="text/css" rel="stylesheet">
</head>
<body style="background: #ffffff;">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
    <td width="60%" valign="top" align="left">    
    <?
        $count_sections = "0";
        while($r__ = $db->fetchAssoc()){
            echo "<table width='100%' border='0' cellspacing='0' cellpadding='0' style='margin-top:".(($count_sections > "0") ? "8px" : "0px").";'>
            <tr bgcolor='#dfdcd5'>
                <td><div class='section_title_left' style='color:#dfdcd5' ></div></td>
                <td width='100%' align='left' bgcolor='#dfdcd5'><div class='section_title' style='background-color:dfdcd5' ><div class='section_title_text' style='background-color:dfdcd5' >".$r__['name']."</div></div></td>  
                <td><div class='section_title_right'></div></td>
            </tr>
            </table>
            <table width='100%' border='0' cellspacing='0' cellpadding='0' class='text'>
            <tr><td align='left' style='border:1px solid #efefef;'>";
            $db2->query("SELECT * FROM "._DB_PREFIX."menu WHERE is_menu_group = 0 AND is_hidden = 0 AND is_dashboard_icon = 1 ".$criterio."AND parent_id = ".intval($r__['id'])." ORDER BY name ASC");
            echo "<table border=0><tr>";
            while($r___ = $db2->fetchAssoc()){
                echo "<td width='110px' align='center' valign='top'><a href='".$r___['page_name']."' class='table_style1' style='color: #333333'>";
				$imagen="images/".$r___['icon'];
				
                if($r___['icon'] != ""){ echo "<div style='display:block; width:38px; height:38px; border:1px solid #cccccc;'><img src='$imagen' width='38' height='38'/></div>"; }
                echo $r___['name']."</a></td>";
            }
            echo "</tr></table>";
            echo "</td></tr></table>";
            $count_sections++;
        }

    ?>
    </td>
    <td width="1%">&nbsp;</td>    
    <td width="39%" style='border:1px solid #efefef;'>
        <h4 align="center"><?php echo $_SESSION['adm_username']; ?>/
		Bienvenido al Panel Administrativo!</h4>
		<h5 align="center"><? echo date("d/m/Y");  ?></h5>
		<? if ($_SESSION['tipousuario'] =="Usuario")  
		      $empresa=$_SESSION['empresa'];
		   else
		     $empresa="Empresa de Envios";
		
		?>
		<h5 align="center">Empresa Activa:<?=$empresa; ?> </h5>
    </td>
</tr>
</table>
</body>
</html>